package org.dromara.file.config;

import io.minio.MinioClient;
import org.dromara.common.core.config.MinioConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;

@Configuration
public class MinioAutoConfiguration {

    @Autowired
    private MinioConfig minioConfig;

    @Bean
    @DependsOn("minioConfig")
    public MinioClient minioClient() {
        System.out.println("自动注入minioClient"+minioConfig.getUrl()+","+minioConfig.getAccessKey()+","+minioConfig.getSecretKey());
        return   MinioClient.builder().endpoint(minioConfig.getUrl()).credentials(minioConfig.getAccessKey(), minioConfig.getSecretKey()).build();

    }
}
